package com.donquijote.proxy.client;

import com.donquijote.proxy.service.OrderService;
import com.donquijote.proxy.service.impl.OrderServiceImpl;
import com.donquijote.proxy.subgroup.ProxyUtil;
import com.donquijote.proxy.subgroup.TimeInvocationHandler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author 421527548@qq.com
 * @version V1.0
 * @title
 * @description
 * @date 2022-11-28 11:03
 */
public class Client {
    public static void main(String[] args) {

        //创建对象
        OrderService orderService = new OrderServiceImpl();
        //创建代理类
/*        OrderService newProxyInstance = (OrderService) Proxy.newProxyInstance(orderService.getClass().getClassLoader(),
                orderService.getClass().getInterfaces(),
                new TimeInvocationHandler(orderService));*/

        OrderService newProxyInstance = (OrderService) ProxyUtil.newTimerProxy(orderService);
        //调用代理对象的代理方法
        String s = newProxyInstance.detail();
        System.out.println(s);

        newProxyInstance.generate();
        newProxyInstance.modify();
    }
}
